Skip to content

perf(agc): audit a cached template only after the host import set changed - #9012

Closed
SP4C3B4R-8 wants to merge 1 commit into
boykopovar:mainfrom
SP4C3B4R-8:perf/template-audit-import-set
Closed

SP4C3B4R-8 wants to merge 1 commit into
boykopovar:mainfrom
SP4C3B4R-8:perf/template-audit-import-set

Conversation

@SP4C3B4R-8

@SP4C3B4R-8 SP4C3B4R-8 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

What

#8047 (@fisherjoey) made a cached ShaderResources take the full walk instead of the fast proof once its last full walk is older than APS5_TEMPLATE_AUDIT_MS (1000 ms). The case it names is a sampled lookup whose answer changes without any lookup running: a snapshot whose surface became host-imported is viewed through its storage image from then on. That answer depends on HostImportCovers, so it can only change when the set of host imports changes.

On a committer-bound scene the audit is a steady cost. Astro Bot (PPSA21564), Crash Site hub, has ~1,600 cached templates, so it runs ~7,700 full walks per 10 s, about 44 µs each. In these runs no audit failed a template (failed 0).

This PR keeps the interval and adds one condition: the audit runs only when a host import was added or retired since the template's last full walk.

  • GuestBufferMemory.cpp keeps a process-wide importSetGeneration, read by HostImportSetGeneration(). bumpEpoch(state) replaces every ++state.epoch (retireImport, the device change in refreshImports, ClearHostImports) and bumps the generation too; importSetChanged() follows the import insert in importRunAt.
  • ShaderResources records the generation when it is built and at the start of each full walk (walkImportGeneration). The audit condition becomes TemplateAuditDue(lastFullWalk) && (AuditEveryInterval() || walkImportGeneration != HostImportSetGeneration()).
  • The audits that an import change starts are spread out: at most APS5_TEMPLATE_AUDIT_BUDGET (default 8, 0 = no limit) start per 4 ms across all templates. A template over the budget keeps the fast proof and audits at a later use.
  • ProofReport::audited says whether the proof took the full walk because of the audit.
  • APS5_TEMPLATE_AUDIT_ALWAYS=1 restores the audit at every interval, without the budget. APS5_TEMPLATE_AUDIT_MS=0 still turns it off.

The released-texture check from #8047 is unchanged.

Tested

Windows 11, RTX 5070 Ti (NVIDIA 617.42), Ryzen 7 7800X3D, MinGW GCC 15.2, Release. First measured on main 27c88a8 (table below). Rebased on main d6eafa5 on 10-22, measured again and retested (see the review reply for the captures).

  • Astro Bot Crash Site, warm caches, APS5_PROFILE_DRAW=1, same session:
fps revalidate per 10 s full walks per 10 s (audit)
main 9.86 1542 ms 10,534 (7,982)
this PR 10.37 1162 ms 2,367 (0)
main + APS5_TEMPLATE_AUDIT_MS=0 (two runs) 10.45 / 10.45 1180 ms 2,423
main again (two runs) 9.89 / 9.78 1530 ms 10,358

Frame dumps of the hub with this PR look the same as main.

  • 10-22, rebased build 19191f4, same session: 10.10 fps with this PR vs 9.89 with APS5_TEMPLATE_AUDIT_ALWAYS=1. Audits per 10 s with this PR: 1, 15, 78, 157, 14 through the menu and the load, then 0 in the level. Committer busy per frame (tools/trace_digest.py): 46.5 vs 49.4 ms.
  • SampledCacheBudget resource-lookup-changed: past the interval with no import change, and after a write to an unrelated surface, the proof stays fast and is not audited. After a host import of an unrelated surface the next proof past the interval is audited and keeps the bound texture. After the import of the bound surface the proof fails and the rebuilt template binds the storage view. Mutation: without the insert bump the test fails at the audit step.
  • agc_driver_graphics_tests and 124 ctests (*draw*, *stencil*, *indirect*, *multisample*, *msaa*, *target*, *pass*, *sampled_cache*, *resource_cache*, *host_import*): all pass apart from the relinker test unused_filter_indirect, which does not touch this code.
  • python tools/check_conventions.py --base origin/main: all checks passed.

Performance report

Capture on main and with this change, same title, scene and machine, by @panicDa3m0n (full table, profiled pair and all twelve summary lines in his comment and the comment after it). Astro Bot Crash Site, 3840x2160, RTX 4070 Ti SUPER (NVIDIA 616.64), i7-11700K, Windows 10.0.26200, MinGW GCC 15.2 Release, main d6eafa5 (this head's parent) against 19191f4, APS5_TRACE_SECONDS=150:5, six alternated rounds.

  • Graphics.Draw on the committer is lower in all six rounds, with either build first: −8.5, −5.7, −5.6, −5.8, −4.9, −5.5 ms per frame.
  • Profiled pair: audit walks about 6,300 per 10 s on main, none with this PR; revalidate 1,734.7 against 1,606.2 ms per 10 s; 35.6 against 33.1 µs per pipelined commit; no failed proof.
  • Frame time is level on that machine: it is bound by the GPU (about 150 ms per present) and by the queue 0 worker (98.7-98.9% busy), so the committer saving does not reach the frame there. On comparable windows the medians differ by about 1 ms of GPU busy and 1.5 ms of frame p50, inside the run-to-run spread.
  • Linux/RADV, Sky Garden, RX 9070 XT (@EdouardSence, comment): level and clean, no device loss or VUID.

Round 1 summary lines (main, then this PR):

{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":4972,"ms":5147.612},"presents":31,"frame_ms":{"p50":167.36,"p90":175.426,"p99":177.992,"max":177.992},"gpu_busy_ms_per_present":139.637,"worker_busy_pct":{"queue worker 0x0":98.759,"queue worker 0x40":97.698,"queue worker 0x48":88.554,"queue worker 0x46":4.664},"top_phases_ms_per_frame":{"Driver.Packet":480.607,"Driver.Packet.memory_wait":274.15,"Driver.Packet.draw":97.616,"Driver.Draw":96.491,"Graphics.Draw":85.504,"Graphics.Draw.draw_and_resource_release":68.385,"Driver.Draw.shader_compile_and_link":54.439,"Driver.Packet.prepare_memory":45.847},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-8152.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2672,"ms":5036.035},"presents":29,"frame_ms":{"p50":175.86,"p90":181.506,"p99":184.268,"max":184.268},"gpu_busy_ms_per_present":157.641,"worker_busy_pct":{"queue worker 0x0":98.774,"queue worker 0x40":97.846,"queue worker 0x48":94.081,"queue worker 0x46":9.056},"top_phases_ms_per_frame":{"Driver.Packet":520.138,"Driver.Packet.memory_wait":295.873,"Driver.Packet.draw":88.37,"Driver.Draw":87.244,"Graphics.Draw":77.007,"Driver.Packet.prepare_memory":61.107,"Graphics.Draw.draw_and_resource_release":59.743,"Driver.Packet.dispatch":53.233},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-22164.json.gz"}

tools/trace_digest.py, first line of each:

aps5-trace-d6eafa54d046-8152.json.gz: **seconds 150:5** from present 4972: 31 presents, frame p50 167.4 / p90 175.4 / p99 178.0 / max 178.0 ms, GPU busy 139.6 ms per present
aps5-trace-19191f4ea263-22164.json.gz: **seconds 150:5** from present 2672: 29 presents, frame p50 175.9 / p90 181.5 / p99 184.3 / max 184.3 ms, GPU busy 157.6 ms per present

Traces: round 1, 2, 3, 4, 5, 6.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Windows 11
  • AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added perf Performance change perf numbers missing perf pull request without a before and after summary line labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown

This pull request is labeled perf, so it needs the summary line of a capture on main and one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste both aps5-summary.jsonl lines, attach the two traces and add the output of tools/trace_digest.py.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 1896 docs/dev/ENVIRONMENT.md
PR 2434 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 4472 docs/dev/ENVIRONMENT.md
PR 5021 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 5372 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6146 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6186 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6194 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6223 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6340 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6412 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6548 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6804 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 6913 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6918 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 6924 docs/dev/ENVIRONMENT.md
PR 6970 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 7449 docs/dev/ENVIRONMENT.md
PR 7457 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 7514 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 7604 docs/dev/ENVIRONMENT.md
PR 7622 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
docs/dev/ENVIRONMENT.md
PR 7643 docs/dev/ENVIRONMENT.md
PR 7689 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 8004 docs/dev/ENVIRONMENT.md
PR 8212 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 8246 docs/dev/ENVIRONMENT.md
PR 8484 docs/dev/ENVIRONMENT.md
PR 9248 docs/dev/ENVIRONMENT.md
PR 9289 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 9345 docs/dev/ENVIRONMENT.md
PR 9356 docs/dev/ENVIRONMENT.md
PR 9387 docs/dev/ENVIRONMENT.md
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
docs/dev/ENVIRONMENT.md
PR 9592 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9712 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 9852 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 9875 docs/dev/ENVIRONMENT.md
PR 9884 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 9897 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 9999 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10043 docs/dev/ENVIRONMENT.md
PR 10049 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10064 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10141 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
docs/dev/ENVIRONMENT.md
PR 10442 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 10443 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 10492 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10497 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10678 docs/dev/ENVIRONMENT.md
PR 10743 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 10757 docs/dev/ENVIRONMENT.md
PR 10894 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 10920 core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 11435 docs/dev/ENVIRONMENT.md
PR 11436 docs/dev/ENVIRONMENT.md
PR 11444 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 11551 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12157 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 12324 docs/dev/ENVIRONMENT.md
PR 12544 docs/dev/ENVIRONMENT.md
PR 12575 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
PR 12745 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
docs/dev/ENVIRONMENT.md
PR 12746 docs/dev/ENVIRONMENT.md
PR 12827 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 12840 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 12849 docs/dev/ENVIRONMENT.md
PR 12855 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12863 docs/dev/ENVIRONMENT.md
PR 12895 docs/dev/ENVIRONMENT.md
PR 12930 docs/dev/ENVIRONMENT.md
PR 12944 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 12970 docs/dev/ENVIRONMENT.md
PR 13148 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 13248 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 13263 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 13707 docs/dev/ENVIRONMENT.md
PR 13793 docs/dev/ENVIRONMENT.md
PR 13796 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 13809 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 13863 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 13920 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 13928 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
docs/dev/ENVIRONMENT.md
PR 13929 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
core/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cpp
docs/dev/ENVIRONMENT.md
PR 13963 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14032 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14051 docs/dev/ENVIRONMENT.md
PR 14219 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14260 docs/dev/ENVIRONMENT.md
PR 14262 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 14344 docs/dev/ENVIRONMENT.md
PR 14367 docs/dev/ENVIRONMENT.md
PR 14794 docs/dev/ENVIRONMENT.md
PR 14871 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 14944 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15015 docs/dev/ENVIRONMENT.md
PR 15059 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 15136 docs/dev/ENVIRONMENT.md
PR 15169 docs/dev/ENVIRONMENT.md
PR 15295 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15296 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15297 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15302 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15456 docs/dev/ENVIRONMENT.md
PR 15505 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15520 docs/dev/ENVIRONMENT.md
PR 15529 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 15548 docs/dev/ENVIRONMENT.md
PR 15551 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15563 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15569 docs/dev/ENVIRONMENT.md
PR 15570 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 15572 docs/dev/ENVIRONMENT.md
PR 15621 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15658 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15659 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15671 docs/dev/ENVIRONMENT.md
PR 15674 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 15702 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15710 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15719 docs/dev/ENVIRONMENT.md
PR 15738 docs/dev/ENVIRONMENT.md
PR 15792 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 15917 docs/dev/ENVIRONMENT.md
PR 15918 docs/dev/ENVIRONMENT.md
PR 15919 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
docs/dev/ENVIRONMENT.md
PR 15936 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15941 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 15974 docs/dev/ENVIRONMENT.md
PR 16115 docs/dev/ENVIRONMENT.md
PR 16116 docs/dev/ENVIRONMENT.md
PR 16130 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 16217 docs/dev/ENVIRONMENT.md
PR 16263 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 16286 core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
docs/dev/ENVIRONMENT.md
PR 16294 docs/dev/ENVIRONMENT.md
PR 16312 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 16354 docs/dev/ENVIRONMENT.md
PR 16371 docs/dev/ENVIRONMENT.md
PR 16372 docs/dev/ENVIRONMENT.md
PR 16375 core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp
PR 16427 docs/dev/ENVIRONMENT.md
PR 16474 core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp
PR 16572 docs/dev/ENVIRONMENT.md

@fisherjoey

Copy link
Copy Markdown
Contributor

Thanks for measuring this. The 44 µs per walk on Astro Bot is a real cost, and gating the audit on import changes makes sense if that is the only thing it has to catch.

One data point from Demon's Souls before this goes in. The audit in #8047 is what fixed the DS level crawl (#8040). The released-texture check alone was not enough: with only that check, 2 of 2 runs still crawled (indexed-indirect draw ratio 439 and 436, normal is 200 to 225). With the timed audit added, 3 of 3 were normal on the old base and 3 of 3 on main 6762694.

What I don't know yet is which change the audit catches on DS. If it is always a host import being added or retired, this PR keeps the fix. If something else changes a lookup's answer there, gating on importSetGeneration would bring the crawl back.

I'm running DS with this PR on top of our stack tonight and will post the crawl ratios and the audit failure counts here when they're in.

AI-assisted: yes

@github-actions github-actions Bot added docs agc libSceAgc* labels Oct 21, 2026
@fisherjoey

fisherjoey commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up with the Demon's Souls numbers. This PR doesn't bring the crawl back on DS, and the audits it skips are not ones that fail there.

Setup: our DS stack (main 6762694 plus #8047 and a few of our open fixes) with this PR cherry-picked, plus a local counter for audits that the import gate skips, audits that fail, and failures with no import change since the template's last full walk. Three 900 s runs from boot into the first level, judged by the indexed-indirect draw ratio from #8040 (normal 200 to 225, crawl 410 to 475) and a screenshot at t+400 s. Counts are totals over the whole run.

run audit mode crawl? ratio, last half median audit walks audits skipped by the gate audits failed failed with no import change
1 this PR no 216 9,536 4,140,321 40 0
2 APS5_TEMPLATE_AUDIT_ALWAYS=1 no 214 390,832 0 39 0
3 this PR no 214 9,642 5,054,035 40 0

With the audit forced at every interval (run 2), 39 audits failed, and every one of them came after a host import was added or retired. None failed without an import change, so on DS the gate keeps exactly the case the audit exists for. All the failures fall in the title, menu and level-load stretch, where the import set churns. In the level itself no audit failed in any run.

No crashes, and the screenshots are clean. Steady presents were 9.79 per 10 s with this PR and 9.57 with the audit forced, about 2% better (run 1 overlapped a build on the same machine, so I left its fps out).

Caveats: one title and three runs. A lookup change that doesn't go through the host import set would get past the gate, and DS showed none.

(Edited: the first version of this comment quoted counts from the last 10 s report only, which showed 0 failures. These are whole-run totals.)

AI-assisted: yes

@CnRJay CnRJay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cost is measured on a scene where it matters (Astro Bot Crash Site: ~7,700 audit walks at about 44 us per 10 s; revalidate 1,542 ms to 1,162 ms per 10 s; APS5_TEMPLATE_AUDIT_MS=0 gives the same 1,180 ms, so the PR reaches the "audit off" cost) and the reasoning for the condition is sound: the answer the audit guards depends on HostImportCovers, which can only change when the import set does.

  • The generation is process-wide. Any import added or retired anywhere makes walkImportGeneration != HostImportSetGeneration() true for every cached template at its next use past the interval. With ~1,600 templates at ~44 us that is about 70 ms of audit walks landing in the frames right after one import, on the committer, which is the bound thread in this scene. In a scene that imports regularly (streaming, #8926's rewatch, windows retiring and being replaced) the saving shrinks and the cost arrives as hitches. Please post the audits per 10 s and the worst frame time on a scene that streams imports, or stagger it: audit at most N templates per frame after a change, oldest lastFullWalk first.
  • The test says the import "also fails the fast proof by itself (full path, failure Other), so the audit is not what catches it there". So no test shows the audit catching a stale answer after an import change, which is the only case it still exists for, and the only case this PR can break. Add one where the fast proof would pass and only the audit catches it, with an import added (the audit runs) and with an unrelated change (it doesn't).
  • HostImportSetGeneration is bumped "wherever the registry's epoch is bumped" and where an import is inserted. List the sites in the description and add a test that fails if a new bump site forgets it, since a missing bump silently disables the audit.

@SP4C3B4R-8
SP4C3B4R-8 force-pushed the perf/template-audit-import-set branch from 5771aac to 19191f4 Compare October 22, 2026 08:41
@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@CnRJay thanks, all three points are addressed in the new push (rebased on main d6eafa5, it was conflicting). @fisherjoey thanks for the Demon's Souls runs: 39 audit failures with the audit forced, all after an import change, is the case the gate keeps.

1. Audits after one import change are now spread out. ImportAuditAdmitted() lets at most APS5_TEMPLATE_AUDIT_BUDGET audits start per 4 ms (default 8, 0 = no limit). The audits that an import change starts are counted across all templates. A template that is over the budget keeps the fast proof and audits at a later use. With ~1,600 templates, the walks after one import take about 0.8 s at most 88 µs per 4 ms, instead of ~70 ms in one go. That is still ~2,000 audits/s, above the old steady rate (~800/s here), so no template waits long. APS5_TEMPLATE_AUDIT_ALWAYS=1 is not limited and keeps the old behaviour.

Audits per 10 s on Astro Bot (PPSA21564) with this PR, from boot through the menu, the hub load and the Crash Site hub (APS5_PROFILE_DRAW=1): 1, 15, 78, 157, 14, then 0 for every report in the level. With APS5_TEMPLATE_AUDIT_ALWAYS=1: ~400 per 10 s in the menu, 7,200-8,200 in the level. The import churn is in the load stretch, and the worst 10 s there is 157 walks (~7 ms).

2. A test where only the audit runs after an import, and one where it doesn't. ProofReport now has audited (the proof took the full walk because of the audit). resource-lookup-changed now checks, in order:

  • past the interval with no import change: fast proof, not audited;
  • a guest write to an unrelated, non-imported surface, past the interval: fast proof, not audited;
  • a host import of an unrelated surface (separated from the bound one by a reserved gap, so the import does not cover it): the generation moves, and the next proof past the interval is audited, takes the full walk and keeps the bound texture; the proof after that is fast again;
  • then the import of the bound surface: the proof fails and the rebuilt template binds the storage view, as before.

Mutation: with the bump after the import insert removed (and the generation Require taken out), the test fails at "a proof past the audit interval after a host import was added did not audit the template".

About the last step: in this fixture the import of the bound surface fails the fast proof itself. The import re-arms write tracking of the range, so the fast proof fails on Collect before the audit is reached. I found no host-only way to change HostImportCovers for a bound surface without touching its tracking, so the test checks the gate on the unrelated import instead. The DS counts above show the real case where the fast proof passes and only the audit catches the change.

3. Bump sites. There are no separate bumps any more. bumpEpoch(state) replaces every ++state.epoch (3 sites on current main: retireImport, the device change in refreshImports, ClearHostImports), and importSetChanged() follows the one state.imports.emplace in importRunAt. A new retire path that moves the epoch gets the generation with it. The test above fails if the insert bump is missing. They are listed in the description.

Performance capture (same build, 19191f4, Crash Site hub, warm caches, APS5_TRACE_SECONDS=140:10; "main" = APS5_TEMPLATE_AUDIT_ALWAYS=1, which is main's audit):

{"commit":"19191f4ea263","env":{"APS5_TEMPLATE_AUDIT_ALWAYS":"1","APS5_TRACE_SECONDS":"140:10",...},"presents":104,"frame_ms":{"p50":96.4,"p90":105.0,"p99":108.5,"max":110.2},"gpu_busy_ms_per_present":62.3}
{"commit":"19191f4ea263","env":{"APS5_TRACE_SECONDS":"140:10",...},"presents":105,"frame_ms":{"p50":95.8,"p90":103.3,"p99":108.4,"max":108.5},"gpu_busy_ms_per_present":64.6}

tools/trace_digest.py: draw committer busy 49.4 ms per frame with the audit forced, 46.5 ms with this PR (-6 %). Queue 0's worker bounds this scene on current main: it is busy ~80 of ~96 ms per frame, 33 ms of that in Driver.Draw.shader_compile_and_link. So the committer saving shows up only partly in FPS. Untraced runs, same session: 10.10 fps with this PR, 9.89 with the audit forced. The full summary lines and both traces are available if you want them attached.

Tests on the rebase: agc_driver_graphics_tests and 124 ctests (*draw*, *stencil*, *indirect*, *multisample*, *msaa*, *target*, *pass*, *sampled_cache*, *resource_cache*, *host_import*) pass, except unused_filter_indirect, a relinker test that does not touch this code. Conventions pass.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026
@oneandonlydean oneandonlydean self-assigned this Oct 22, 2026
@panicDa3m0n

Copy link
Copy Markdown

@SP4C3B4R-8, this still carries perf numbers missing. If it helps, I can run an alternated A/B at ASTRO BOT's Crash Site (Windows 11, RTX 4070 Ti SUPER), main against this head, four rounds, and post the summary lines, the trace_digest.py heads and the traces here for you to use in the description. Say if you'd like it, or if you'd rather capture the pair yourself.

panicDa3m0n added a commit to panicDa3m0n/NativeFrame that referenced this pull request Oct 23, 2026
@SP4C3B4R-8

Copy link
Copy Markdown
Contributor Author

@panicDa3m0n yes please, that would help: an alternated A/B at Crash Site, main against 19191f4, with the summary lines, the trace_digest.py heads and the traces. I'll put them in the description. Thanks!

AI-assisted: yes (Claude Code)

@panicDa3m0n

Copy link
Copy Markdown

Thanks @SP4C3B4R-8. I'll run the alternated pair at Crash Site, main against 19191f4ea, and post the summary lines, the trace_digest.py heads and the traces here.

@panicDa3m0n

Copy link
Copy Markdown

@SP4C3B4R-8, the alternated A/B you asked for: main d6eafa5 against this head 19191f4 at Crash Site, plus one profiled pair for the template counters. d6eafa5 is the head's parent, so the two builds differ only by this pull request.

  • Machine: NVIDIA GeForce RTX 4070 Ti SUPER (NVIDIA 616.64), 11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz, 32599 MiB, Windows 10.0.26200; ASTRO BOT (PPSA21567) 01.019.000, 3840x2160.
  • Builds: Release, MinGW-w64 GCC 15.2.0; d6eafa54d046 and 19191f4ea263 in the summary lines.
  • Capture: APS5_TRACE_SECONDS=150:5 and APS5_HOST_IMPORT_MIB=13312, nothing else; warm shader caches; all in one session, with no driver reset.
    • Order: first a discarded warm-up run of main, then four rounds with main first. Then a discarded warm-up run of this PR, and two rounds with this PR first.
    • Why the second block: main drifted during the first four rounds (GPU busy per present 139.6, 149.4, 150.9, 155.3; frame p50 167.4 to 175.6). With main always first, that drift by itself counted against this PR.
Run Round Order in round Build Commit Window starts at present Frame p50 / p90 / p99 (ms) GPU busy per present (ms) Graphics.Draw (ms per frame)
1 1 first main d6eafa54d 4972 167.4 / 175.4 / 178.0 139.6 85.5
2 1 second this PR 19191f4ea 2672 175.9 / 181.5 / 184.3 157.6 77.0
3 2 first main d6eafa54d 2681 168.8 / 176.8 / 180.8 149.4 80.3
4 2 second this PR 19191f4ea 2698 168.1 / 175.0 / 176.1 154.2 74.6
5 3 first main d6eafa54d 2670 171.4 / 177.7 / 185.2 150.9 80.6
6 3 second this PR 19191f4ea 2673 173.5 / 178.8 / 182.6 154.1 75.0
7 4 first main d6eafa54d 2697 175.6 / 186.0 / 192.9 155.3 80.6
8 4 second this PR 19191f4ea 2610 187.1 / 199.3 / 203.5 170.0 74.8
9 5 first this PR 19191f4ea 2683 176.6 / 180.7 / 186.0 152.5 78.2
10 5 second main d6eafa54d 2715 174.8 / 185.1 / 189.2 157.0 83.2
11 6 first this PR 19191f4ea 2696 171.7 / 178.2 / 180.3 144.4 78.1
12 6 second main d6eafa54d 4796 166.0 / 175.0 / 179.8 136.2 83.6

Per round (rounds 1 to 6), this PR minus main:

  • frame p50: +8.5, −0.7, +2.1, +11.5, +1.9 and +5.7 ms;
  • GPU busy per present: +18.0, +4.9, +3.2, +14.7, −4.4 and +8.2 ms;
  • Graphics.Draw: −8.5, −5.7, −5.6, −5.8, −4.9 and −5.5 ms per frame.

Three runs had their 150 s window start near present 4,800-5,000 instead of 2,600-2,700: runs 1 and 12 (both main) and the discarded warm-up of this PR. They are also the three fastest runs of the session, at 136.2-139.6 ms of GPU busy and 165.0-167.4 ms of frame p50. Leaving runs 1 and 12 out, the medians are 153.1 ms of GPU busy and 173.1 ms of frame p50 for main, against 154.1 ms and 174.7 ms for this PR.

Where the time goes, from the traces: ms per present summed over the thread, this PR minus main, rounds 1 to 6.

Slice Thread Rounds 1 to 6
Graphics.Draw draw committer −9.5, −5.7, −5.6, −5.9, −4.8, −6.2
Driver.Draw.draw_enqueued queue worker 0x0 −7.0, −0.1, −9.9, −12.6, −3.0, −1.3
Vulkan.Dispatch.shader_resources queue worker 0x0 +10.1, +5.7, +0.6, +21.7, +7.4, +6.1
Resources.Complete queue worker 0x0 +2.8, +5.7, +0.5, +21.8, +7.3, −1.2
Recorder.Sync queue worker 0x0 +6.0, +5.9, +0.5, +3.5, +7.8, +2.9

The queue 0 worker is busy 98.7 to 98.9% of the window in all twelve runs.

A profiled pair, separate from the A/B (APS5_PROFILE_DRAW=1 and APS5_HOST_IMPORT_MIB=13312, one 200 s run per build, main first, the last 10 s windows in the level):

  • [rescache] revalidate (10 s), last five windows:
    • main: 125,058 to 128,191 calls, 1,687.7 to 1,754.7 ms, full walks 7,548 to 7,756 (audit 6,210 to 6,316), failed 0.
    • this PR: 124,357 to 128,095 calls, 1,578.3 to 1,646.8 ms, full walks 1,350 to 1,441 (no audit), failed 0.
    • The other full-walk reasons are the same on both sides: pending image about 700, memory changed about 500, depth surface about 165.
  • [draw] pipelined, last three windows: 34.9, 35.8 and 36.2 µs per commit on main, against 32.7, 32.9 and 33.6 with this PR, at 175,000 to 180,000 commits per 10 s on both.
  • [present], last five windows: 55 to 57 presents per 10 s on both. GPU busy per frame was 146.0 to 149.1 ms on main, with idle gaps of 29.8 to 36.1 ms, against 156.6 to 161.7 ms with idle gaps of 23.2 to 25.0 ms with this PR. This pair ran in a fixed order too, so the GPU numbers carry the same caveat as the A/B; the counts above do not depend on the order.

Reading of the numbers (AI-assisted):

  • The mechanism works as described.
    • In the level the audit walks go from about 6,300 per 10 s to none.
    • Revalidation takes about 130 ms less per 10 s: the mean of the five windows is 1,734.7 ms against 1,606.2 ms.
    • A commit costs about 2.6 µs less: the mean of the three windows is 35.6 µs against 33.1 µs.
    • Graphics.Draw on the committer is lower in all six rounds, with either build first. No proof failed on either side.
  • The frame does not show it on this machine. Here main is bound by the GPU (about 150 ms per present) and by the queue 0 worker.
    • The GPU and frame differences are consistent with the run order and with where the window lands; on these runs they cannot be attributed to the build.
    • With this PR first, the GPU difference is −4.4 and +8.2 ms. Run 12, the main run of round 6, is one of the three shifted windows.
    • On comparable windows the medians differ by about 1 ms of GPU busy and 1.5 ms of frame p50, inside the run-to-run spread.
  • Where the saved committer time goes. The queue 0 worker spends less time in Driver.Draw.draw_enqueued. It spends more time in Recorder.Sync and Vulkan.Dispatch.shader_resources while preparing dispatches, higher with this PR in all six rounds, so it waits on GPU completions instead of on the committer. On a machine where the GPU is not the limit, the committer saving can reach the frame, as in the runs in the description.
Summary lines, in run order
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":4972,"ms":5147.612},"presents":31,"frame_ms":{"p50":167.36,"p90":175.426,"p99":177.992,"max":177.992},"gpu_busy_ms_per_present":139.637,"worker_busy_pct":{"queue worker 0x0":98.759,"queue worker 0x40":97.698,"queue worker 0x48":88.554,"queue worker 0x46":4.664},"top_phases_ms_per_frame":{"Driver.Packet":480.607,"Driver.Packet.memory_wait":274.15,"Driver.Packet.draw":97.616,"Driver.Draw":96.491,"Graphics.Draw":85.504,"Graphics.Draw.draw_and_resource_release":68.385,"Driver.Draw.shader_compile_and_link":54.439,"Driver.Packet.prepare_memory":45.847},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-8152.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2672,"ms":5036.035},"presents":29,"frame_ms":{"p50":175.86,"p90":181.506,"p99":184.268,"max":184.268},"gpu_busy_ms_per_present":157.641,"worker_busy_pct":{"queue worker 0x0":98.774,"queue worker 0x40":97.846,"queue worker 0x48":94.081,"queue worker 0x46":9.056},"top_phases_ms_per_frame":{"Driver.Packet":520.138,"Driver.Packet.memory_wait":295.873,"Driver.Packet.draw":88.37,"Driver.Draw":87.244,"Graphics.Draw":77.007,"Driver.Packet.prepare_memory":61.107,"Graphics.Draw.draw_and_resource_release":59.743,"Driver.Packet.dispatch":53.233},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-22164.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2681,"ms":5060.239},"presents":30,"frame_ms":{"p50":168.823,"p90":176.758,"p99":180.831,"max":180.831},"gpu_busy_ms_per_present":149.354,"worker_busy_pct":{"queue worker 0x0":98.801,"queue worker 0x40":97.63,"queue worker 0x48":94.542,"queue worker 0x46":8.097},"top_phases_ms_per_frame":{"Driver.Packet":504.052,"Driver.Packet.memory_wait":290.954,"Driver.Packet.draw":85.657,"Driver.Draw":84.509,"Graphics.Draw":80.305,"Graphics.Draw.draw_and_resource_release":63.844,"Driver.Packet.prepare_memory":62.216,"Driver.Draw.shader_compile_and_link":50.704},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-22280.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2698,"ms":5031.162},"presents":30,"frame_ms":{"p50":168.125,"p90":174.995,"p99":176.086,"max":176.086},"gpu_busy_ms_per_present":154.246,"worker_busy_pct":{"queue worker 0x0":98.776,"queue worker 0x40":97.672,"queue worker 0x48":94.193,"queue worker 0x46":9.669},"top_phases_ms_per_frame":{"Driver.Packet":503.252,"Driver.Packet.memory_wait":285.077,"Driver.Packet.draw":86.029,"Driver.Draw":84.894,"Graphics.Draw":74.637,"Graphics.Draw.draw_and_resource_release":58.032,"Driver.Packet.dispatch":56.162,"Driver.Packet.prepare_memory":55.277},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-3816.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2670,"ms":5108.42},"presents":30,"frame_ms":{"p50":171.441,"p90":177.708,"p99":185.174,"max":185.174},"gpu_busy_ms_per_present":150.877,"worker_busy_pct":{"queue worker 0x0":98.818,"queue worker 0x40":98.232,"queue worker 0x48":94.513,"queue worker 0x46":9.605},"top_phases_ms_per_frame":{"Driver.Packet":512.43,"Driver.Packet.memory_wait":292.073,"Driver.Packet.draw":90.816,"Driver.Draw":89.705,"Graphics.Draw":80.562,"Graphics.Draw.draw_and_resource_release":63.864,"Driver.Packet.prepare_memory":59.172,"Driver.Draw.shader_compile_and_link":51.148},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-19564.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2673,"ms":5164.923},"presents":30,"frame_ms":{"p50":173.546,"p90":178.765,"p99":182.587,"max":182.587},"gpu_busy_ms_per_present":154.052,"worker_busy_pct":{"queue worker 0x0":98.751,"queue worker 0x40":97.731,"queue worker 0x48":94.007,"queue worker 0x46":7.956},"top_phases_ms_per_frame":{"Driver.Packet":513.426,"Driver.Packet.memory_wait":296.143,"Driver.Packet.draw":83.251,"Driver.Draw":82.134,"Graphics.Draw":75.004,"Driver.Packet.prepare_memory":67.543,"Graphics.Draw.draw_and_resource_release":58.274,"Recorder.WaitSerial":54.497},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-28320.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2697,"ms":5085.977},"presents":29,"frame_ms":{"p50":175.586,"p90":185.992,"p99":192.942,"max":192.942},"gpu_busy_ms_per_present":155.272,"worker_busy_pct":{"queue worker 0x0":98.766,"queue worker 0x40":97.796,"queue worker 0x48":94.22,"queue worker 0x46":9.693},"top_phases_ms_per_frame":{"Driver.Packet":526.603,"Driver.Packet.memory_wait":298.415,"Driver.Packet.draw":94.59,"Driver.Draw":93.437,"Graphics.Draw":80.565,"Graphics.Draw.draw_and_resource_release":63.973,"Driver.Packet.prepare_memory":58.478,"Driver.Packet.dispatch":54.1},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-13024.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2610,"ms":5078.559},"presents":27,"frame_ms":{"p50":187.094,"p90":199.273,"p99":203.459,"max":203.459},"gpu_busy_ms_per_present":170.02,"worker_busy_pct":{"queue worker 0x0":98.91,"queue worker 0x40":98.229,"queue worker 0x48":93.957,"queue worker 0x46":13.559},"top_phases_ms_per_frame":{"Driver.Packet":572.643,"Driver.Packet.memory_wait":328.882,"Driver.Packet.draw":80.032,"Driver.Draw":78.945,"Graphics.Draw":74.815,"Driver.Packet.prepare_memory":74.155,"Driver.Packet.dispatch":69.102,"Driver.Dispatch":66.452},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-15060.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2683,"ms":5037.46},"presents":29,"frame_ms":{"p50":176.617,"p90":180.722,"p99":185.974,"max":185.974},"gpu_busy_ms_per_present":152.507,"worker_busy_pct":{"queue worker 0x0":98.7,"queue worker 0x40":97.668,"queue worker 0x48":97.613,"queue worker 0x46":9.731},"top_phases_ms_per_frame":{"Driver.Packet":527.101,"Driver.Packet.memory_wait":301.15,"Driver.Packet.draw":88.367,"Driver.Draw":87.224,"Graphics.Draw":78.25,"Graphics.Draw.draw_and_resource_release":60.967,"Driver.Packet.dispatch":59.397,"Driver.Dispatch":56.65},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-2552.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2715,"ms":5022.611},"presents":29,"frame_ms":{"p50":174.751,"p90":185.149,"p99":189.206,"max":189.206},"gpu_busy_ms_per_present":156.952,"worker_busy_pct":{"queue worker 0x0":98.778,"queue worker 0x40":97.612,"queue worker 0x48":93.47,"queue worker 0x46":7.514},"top_phases_ms_per_frame":{"Driver.Packet":514.624,"Driver.Packet.memory_wait":296.292,"Driver.Packet.draw":91.186,"Driver.Draw":90.042,"Graphics.Draw":83.189,"Graphics.Draw.draw_and_resource_release":66.018,"Driver.Packet.prepare_memory":58.756,"Driver.Draw.shader_compile_and_link":52.95},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-5280.json.gz"}
{"commit":"19191f4ea263","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":2696,"ms":5133.729},"presents":30,"frame_ms":{"p50":171.66,"p90":178.243,"p99":180.319,"max":180.319},"gpu_busy_ms_per_present":144.422,"worker_busy_pct":{"queue worker 0x0":98.74,"queue worker 0x40":97.663,"queue worker 0x48":94.21,"queue worker 0x46":9.896},"top_phases_ms_per_frame":{"Driver.Packet":513.659,"Driver.Packet.memory_wait":292.62,"Driver.Packet.draw":89.151,"Driver.Draw":88.03,"Graphics.Draw":78.097,"Graphics.Draw.draw_and_resource_release":60.622,"Driver.Packet.dispatch":55.333,"Driver.Packet.prepare_memory":55.05},"trace_dropped":false,"trace":"aps5-trace-19191f4ea263-8520.json.gz"}
{"commit":"d6eafa54d046","dirty":false,"env":{"APS5_HOST_IMPORT_MIB":"13312","APS5_TRACE_DIR":"<path>","APS5_TRACE_SECONDS":"150:5"},"gpu":"NVIDIA GeForce RTX 4070 Ti SUPER","driver":"NVIDIA 616.64","os":"Windows 10.0.26200","cpu":"11th Gen Intel(R) Core(TM) i7-11700K @ 3.60GHz","cpu_threads":16,"memory_mib":32599,"title_id":"PPSA21567","title":"ASTRO BOT","content_version":"01.019.000","resolution":"3840x2160","window":{"spec":"seconds 150:5","first_present":4796,"ms":5149.502},"presents":31,"frame_ms":{"p50":166.007,"p90":174.995,"p99":179.774,"max":179.774},"gpu_busy_ms_per_present":136.177,"worker_busy_pct":{"queue worker 0x0":98.745,"queue worker 0x40":97.702,"queue worker 0x48":94.349,"queue worker 0x46":8.351},"top_phases_ms_per_frame":{"Driver.Packet":496.525,"Driver.Packet.memory_wait":286.112,"Driver.Packet.draw":92.319,"Driver.Draw":91.195,"Graphics.Draw":83.633,"Graphics.Draw.draw_and_resource_release":66.548,"Driver.Draw.shader_compile_and_link":54.712,"Driver.Packet.prepare_memory":49.09},"trace_dropped":false,"trace":"aps5-trace-d6eafa54d046-13632.json.gz"}
trace_digest.py, first line of each trace, in run order
aps5-trace-d6eafa54d046-8152.json.gz: **seconds 150:5** from present 4972: 31 presents, frame p50 167.4 / p90 175.4 / p99 178.0 / max 178.0 ms, GPU busy 139.6 ms per present
aps5-trace-19191f4ea263-22164.json.gz: **seconds 150:5** from present 2672: 29 presents, frame p50 175.9 / p90 181.5 / p99 184.3 / max 184.3 ms, GPU busy 157.6 ms per present
aps5-trace-d6eafa54d046-22280.json.gz: **seconds 150:5** from present 2681: 30 presents, frame p50 168.8 / p90 176.8 / p99 180.8 / max 180.8 ms, GPU busy 149.4 ms per present
aps5-trace-19191f4ea263-3816.json.gz: **seconds 150:5** from present 2698: 30 presents, frame p50 168.1 / p90 175.0 / p99 176.1 / max 176.1 ms, GPU busy 154.2 ms per present
aps5-trace-d6eafa54d046-19564.json.gz: **seconds 150:5** from present 2670: 30 presents, frame p50 171.4 / p90 177.7 / p99 185.2 / max 185.2 ms, GPU busy 150.9 ms per present
aps5-trace-19191f4ea263-28320.json.gz: **seconds 150:5** from present 2673: 30 presents, frame p50 173.5 / p90 178.8 / p99 182.6 / max 182.6 ms, GPU busy 154.1 ms per present
aps5-trace-d6eafa54d046-13024.json.gz: **seconds 150:5** from present 2697: 29 presents, frame p50 175.6 / p90 186.0 / p99 192.9 / max 192.9 ms, GPU busy 155.3 ms per present
aps5-trace-19191f4ea263-15060.json.gz: **seconds 150:5** from present 2610: 27 presents, frame p50 187.1 / p90 199.3 / p99 203.5 / max 203.5 ms, GPU busy 170.0 ms per present
aps5-trace-19191f4ea263-2552.json.gz: **seconds 150:5** from present 2683: 29 presents, frame p50 176.6 / p90 180.7 / p99 186.0 / max 186.0 ms, GPU busy 152.5 ms per present
aps5-trace-d6eafa54d046-5280.json.gz: **seconds 150:5** from present 2715: 29 presents, frame p50 174.8 / p90 185.1 / p99 189.2 / max 189.2 ms, GPU busy 157.0 ms per present
aps5-trace-19191f4ea263-8520.json.gz: **seconds 150:5** from present 2696: 30 presents, frame p50 171.7 / p90 178.2 / p99 180.3 / max 180.3 ms, GPU busy 144.4 ms per present
aps5-trace-d6eafa54d046-13632.json.gz: **seconds 150:5** from present 4796: 31 presents, frame p50 166.0 / p90 175.0 / p99 179.8 / max 179.8 ms, GPU busy 136.2 ms per present

The traces follow in the next comment, one zip per round with that round's two traces, summary lines and trace_digest.py outputs.

@panicDa3m0n

Copy link
Copy Markdown

Traces of the twelve runs in the comment above, one zip per round with that round's two traces, their aps5-summary.jsonl lines and trace_digest.py outputs. Rounds 1 to 4 ran with main first, rounds 5 and 6 with this PR first.

pr9012-ab-round1.zip
pr9012-ab-round2.zip
pr9012-ab-round3.zip
pr9012-ab-round4.zip
pr9012-ab-round5.zip
pr9012-ab-round6.zip

@EdouardSence

Copy link
Copy Markdown
Contributor

A Linux/RADV data point for 19191f4 (one build with #9899 under it; APS5_TEMPLATE_AUDIT_ALWAYS=1 gives the comparison inside one build).

Setup: ASTRO BOT (PPSA21567) Sky Garden, 3840x2160, no input, headless gamescope, Ryzen 7 7800X3D, RX 9070 XT (RADV Mesa 26.2.4), GCC Release. Base main 9446779 + #9852. Test build: the same plus #9899 (9b4e692) and #9012 (19191f4), both clean merges. All runs: APS5_HOST_IMPORT_MIB=4096 APS5_DRAW_PIPELINE=1 APS5_PIPELINED_DRAWS=32 APS5_PIPELINE_DISPATCH=1, warm caches, two alternating rounds. This scene misses the draw cache on almost every lookup, and the committer and the finisher are the busy driver threads (#7895).

round 1 p50 / p99 ms round 2 p50 / p99 ms
base 210.5 / 247.0 208.4 / 220.2
+ #9899 + #9012 206.5 / 219.5 207.3 / 216.4
+ #9899 + #9012, APS5_TEMPLATE_AUDIT_ALWAYS=1 (#9012's old behaviour) 207.2 / 220.7 207.0 / 219.7

No device loss, page fault or VUID on any run.

With and without APS5_TEMPLATE_AUDIT_ALWAYS=1, the same build gives 206.9 against 207.1 ms. So the audit interval doesn't cost this scene anything measurable, and this PR is level and clean here.

Measured and written by Claude (AI assistant) on a contributor's machine.
AI-assisted: yes

@github-actions github-actions Bot removed the perf numbers missing perf pull request without a before and after summary line label Oct 24, 2026
@ycbuzi

ycbuzi commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

A Windows run of this head on an AMD device and a second NVIDIA generation: Windows 11 Home 10.0.26200, WinLibs GCC 15.2.0 r7 (MinGW-w64 UCRT), Release. 19191f4ea2 merged onto main 14c99b52ac with no conflicts.

The 14 tests built from SampledCacheBudget.cpp (agc_driver_recover_*_allocation, agc_driver_resource_cache_*, agc_driver_sampled_cache_budget* and the rest) ran one GPU at a time, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and ctest -V --repeat until-fail:2. All 14 pass both runs on each device; each log's Vulkan device: line names it:

  • GeForce RTX 4070 SUPER (0x2783), NVIDIA 616.92;
  • GeForce GTX 1650 SUPER (0x2187), NVIDIA 616.92;
  • AMD Radeon(TM) Graphics (1002:164e, RDNA2 iGPU), AMD 32.0.21030.2001.

The build has no errors. Its two warnings are main's existing -Wstringop-overread pair from Graphics/src/PipelineLibrary.cpp. No negative control: the test uses ProofReport::audited and HostImportSetGeneration from this PR, so it doesn't build with main's sources.

AI-assisted: yes (Claude Code)

@QDarkRex

Copy link
Copy Markdown
Contributor

AMD data (amdvlk on Windows), as asked for: ASTRO BOT's Crash Site hub. Every run with this PR is faster than every run of its parent, by about 4 % on average. That is the same direction and size as the NVIDIA numbers. One caveat: switching the audit off altogether on the parent gains less than this PR does, so I cannot attribute the whole difference to skipped audits.

  • Host: Windows 11 (26300), Ryzen 7 5700X, 32 GB RAM, Radeon RX 9060 XT, AMD driver 26.10.1, WinLibs GCC 15.2.0 r7, Release.
  • Builds: this PR's head 19191f4 against its parent.
  • Runs: ASTRO BOT PPSA21564 01.007.000, -lvl hub_crashsite, no input, 300 s each. One warm-up per arm, then three rounds in the order A B / B A / A B, plus two runs of the parent with audits off, in the order listed below. APS5_HOST_IMPORT_MIB=14336 and APS5_TRACE_SUMMARY_EVERY=10 were set in every run. FPS is the mean, and frame p50 and GPU busy the median, of the 10 s windows from 120 s on.
Run Build FPS frame p50 GPU busy / present
1 parent 7.37 132.5 ms 78.7 ms
2 this PR 7.74 129.0 ms 78.7 ms
3 this PR 7.48 134.0 ms 78.6 ms
4 parent 7.21 137.9 ms 78.3 ms
5 parent + APS5_TEMPLATE_AUDIT_MS=0 7.41 135.6 ms 79.2 ms
6 parent 7.25 138.1 ms 78.8 ms
7 this PR 7.48 134.3 ms 78.6 ms
8 parent + APS5_TEMPLATE_AUDIT_MS=0 7.33 136.9 ms 79.0 ms
  • Means: parent 7.28 FPS, this PR 7.57 FPS (+4.0 %). Median frame p50: 137.9 against 134.0 ms. GPU busy per present is unchanged, so the saving is on the CPU side.
  • With audits disabled on the parent (APS5_TEMPLATE_AUDIT_MS=0, which TemplateAuditDue treats as never), the two runs give 7.33 and 7.41 FPS. That is about the parent's own level (7.21–7.37) and below every run of this PR. So on this scene the audit walks alone do not account for the difference, and something else in the change may contribute. Run order or noise is also possible with three rounds.
  • For scale: on main 5d3ab77 with APS5_PROFILE_DRAW=1, this scene's [rescache] revalidate line reads 136k calls and 1252 ms per 10 s, with 6572 full walks, 5709 of them audit.
  • No errors in any run. The warm-up runs had shader-compile stalls, and they are excluded.

AI-assisted: yes (Claude Code). The runs were made on my machine.

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 26, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Thanks for the A/B data in the thread (NVIDIA, AMD on Windows and RADV). Reviewed at 19191f4ea2: the branch now conflicts with current main in GuestBufferMemory.hpp and GuestBufferMemory.cpp. Could you merge main? Once the merged head is up we'll re-check it, and the summary lines already posted here can go into the description for the perf label.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Maintainer edits are on, but this branch conflicts with current main and has been idle, so we carried it as #14838 with your commit credit (Co-authored-by), rebuilt on current main, and we'll close this one once that merges. Thank you!

chitters2004 pushed a commit to chitters2004/AnyPS5 that referenced this pull request Nov 2, 2026
The counter commit below reads APS5_COUNT_WALKS without a row in
docs/dev/ENVIRONMENT.md, which the conventions check refuses. This adds
the row. It goes with the counter and is not for a pull request either.
The report of this branch follows, as in the counter commit fb0be86.

Report (v2)

Branch draft/revalidate-walks-v2, based on upstream main 4ac683f.
Commits:
- 3e89f8a perf(agc): look up only the changed textures when a
  template's memory moved (unchanged from v1)
- 795405a perf(agc): fail a template on a released texture without
  the full walk (unchanged from v1)
- 3ac1c0d perf(agc): find a template's changed elements in one
  tracker query
- 983e273 perf(agc): relook changed elements from lookup recipes
  captured once
- this counter
v1's report (draft/revalidate-walks, aefbec8) still holds for every
reason a walk runs and for the relook and replaced arguments.

What each addition costs, per call and per frame:
- ChangedSince, proof passes: the same single tracker lock and one range
  check per query as UnchangedSinceAll, plus a clear of a thread-local
  vector and one branch per query. Nothing measurable per Revalidate.
- ChangedSince, 'memory changed': v1 took UnchangedSinceAll's lock, then
  one more lock, covers check and range check for each of Q queries to
  name the changed ones. Now one lock and Q range checks. That is Q lock
  round trips saved per failure. Calls per frame: the [walks] relook
  counts (same + differing + fell back).
- Recipes, capture: once per template, on its first relook. One pass
  over its bindings and table elements, which is what v1's relook did on
  every call, plus about 64 bytes per element held by the template.
- Recipes, each later relook: v1 re-enumerated all bindings and table
  elements (narrowing and null-checking every sampled descriptor) to
  reach k changed elements. Now k recipe reads, a sort of k entries by
  build order, and the k lookups. Calls per frame: as above.
- Neither adds work to a proof that passes.

Why the recipes are the walk's lookups:
- The walk derives each lookup from the bindings it is passed.
  ShaderResources::ContentKey puts every non-data binding's descriptor
  words, image shapes and compare bits into the cache key, so a template
  found under that key has its build's descriptors.
- The recipe holds those raw words. Sampled elements are narrowed by
  firstLayerWords at each lookup, as the walk does. Components and
  multisample view type are derived as the walk derives them. Storage
  elements keep the build's mip, written flag and dedupe (index - 1).
- Lookups run in the walk's order: bindings stage by stage, then tables.
- A layout the walk would refuse (no program, more than 8 words per
  element, a table index out of step, counts not matching textures[] or
  storageTextures[]) marks the recipes refused. Those templates take the
  full walk.

Conservative fallbacks, unchanged and tested:
- The relook starts only when 'memory changed' is the fast proof's sole
  failure. That check runs after the pending-registry, key and metadata,
  depth and cache checks.
- The rerun repeats all of those.
- Import identity, the serial loop and staging checks of revalidateFull's
  steps 2 and 3 run after either path, as before.
- A DCC key change fails on keys, and the test shows it takes the full
  walk with no relook.

Lookup-induced eviction: a sampled cache hit never evicts. admitTexture
evicts only on inserting a new texture, and a lookup that inserts has
returned a new object, so the relook returns Differs at that element.
It fails before any rerun, and no evicted object is proved. The test
shows it: a one-byte budget, the changed texture's new copy evicts the
other bound texture, and the proof fails after one relooked lookup.

Tests: ChangedRelook, now two ctest entries.
- agc_driver_changed_relook (imported memory): the 96-texture table
  cases from v1, plus the layered, DCC and eviction cases.
- agc_driver_changed_relook_copied (APS5_NO_HOST_IMPORT=1,
  APS5_VERIFY_PROOFS=1): the same synthetic cases plus a storage image
  and its sampled view over one surface. The table set is not reusable
  without imports, so it runs only in the first entry.
- Results:
  - Storage and sampled alias, same bytes: relooked, 2 lookups, current.
    Changed bytes: relooked, not current.
  - First layer of a 2D array: same bytes relooked with 1 lookup and
    current; changed not current.
  - DCC: same bytes under uncompressed keys relooked, 1 lookup, current.
    Keys cleared to 0x00: full walk, 0 relooked, not current.
  - Eviction: relooked, 1 lookup, not current, the other bound texture
    released.
- Every outcome's current flag matched a run with APS5_NO_CHANGED_RELOOK=1
  (the full walk alone), checked by hand. The copied entry also runs the
  walk beside every relooked proof that passes, through
  APS5_VERIFY_PROOFS.

Mutations, all caught:
- Recipe without the image shape (no first-layer narrowing): "a same-byte
  store in the sampled first layer of a 2D array took the relook ... not
  current", in both modes.
- ChangedSince stopping at the first changed query: "stores over 2
  textures looked 1 textures up again" (imported); the storage alias
  case "took the full walk" (copied).
- v1's mutations still apply.

Also run on lavapipe (Mesa 25.2.8 llvmpipe, LLVM 20.1.2, Ubuntu 24.04),
ANYPS5_NO_SHADER_CACHE=1, 33 of 33 passing with 3 skipped by their own
checks: agc_driver_graphics (with maps fallback), agc_driver_recorder,
agc_copy_guest_bytes, alpha_to_coverage, array_layer_target,
cached_image_multisample_guard, changed_relook (both),
image_table_reuse, lookup_log_fits_build, multisample_fill_host_only,
native_multisample_depth, own_refresh_repack_alias,
packed_mip_tail_target, partially_resident_*, sample_multisample_target,
sampled_cache_budget_*, storage_cache_budget, storage_one_slice_alias,
list_restart, quad_list_index_overflow. check_conventions passes.

Not reached:
- Storage images and views over imported memory: lavapipe compares
  imports instead of write-watching them, so their collect refuses and
  they always take the full walk there. Open boykopovar#14262, boykopovar#6192 and boykopovar#12921
  address that reason.
- Views whose source is a storage image in an image table.
- Depth surfaces, which never produce a changed query.
- A hardware GPU, the validation layer, and the title's real cost. Run
  APS5_COUNT_WALKS=1 on GTA V for calls per frame.

Overlaps as in v1: boykopovar#10894, boykopovar#9012, boykopovar#11444, boykopovar#14262, boykopovar#12575. No speed claims.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011mLh2cdhBwJrK5hBZGnNyy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011mLh2cdhBwJrK5hBZGnNyy
oneandonlydean added a commit that referenced this pull request Nov 4, 2026
Carry #9012 while preserving current recent-import and insertion bookkeeping. Exercise joined import generation and stable repeated lookups.

Co-authored-by: SP4C3B4R-8 <SP4C3B4R-8@users.noreply.github.com>
@oneandonlydean

Copy link
Copy Markdown
Collaborator

Hi @SP4C3B4R-8,

Thank you for this change and for the A/B data on NVIDIA, AMD and RADV. The carry, #14838, merged into main on 4 Nov with your commit credit, so this PR is covered and I'm closing it as we said we would once that landed.

If anything from this branch didn't make it into #14838, say so here and we'll pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs needs rebase Conflicts with main, rebase needed perf Performance change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants